Repository navigation
Conversation
|
Also yea the codes kind of a mess right now i just want feedback right now and let you test out the gui. It will be cleaned up after. |
TheFujirose
left a comment
There was a problem hiding this comment.
Fix linter and respond to comments. And make some files. note you can edit files in src/components/hud/telemetry instead of adding all to the same file.
| ShipRudderVisualizerPanel, | ||
| TacticalMapPanel, | ||
| } from "../src"; | ||
| import { useAppDispatch, startSimulation, regenerateMockTelemetry } from "../src/store"; |
| /** | ||
| * @file TelemetryDashboard.tsx | ||
| * | ||
| * @description | ||
| * This component serves as the main telemetry dashboard for the ASV. | ||
| * It aggregates various telemetry components such as the map, speedometer, compass, task information, battery levels, signal strength, and a live log of telemetry events. | ||
| * The dashboard is designed to provide a comprehensive overview of the ASV's status and performance in real-time. | ||
| * | ||
| * @author Carson Fujita | ||
| * @license MIT | ||
| * | ||
| * @remarks | ||
| * - The component uses React and Material-UI for the user interface, and Redux for state management. | ||
| * - It includes a background image stream from the ASV, overlaid with telemetry data and a collapsible log drawer at the bottom. | ||
| * - When there is no stream and no `placeholderSrc` prop, a themed empty background is shown instead. | ||
| * - The dashboard is responsive, with adjustments for mobile and desktop views. | ||
| * - The border color of the dashboard changes based on the ASV's status to provide a quick visual indicator of its condition. | ||
| * @example | ||
| * ```tsx | ||
| * <TelemetryDashboard placeholderSrc={fallbackJpg} title="Live Log" /> |
There was a problem hiding this comment.
What happened to my comments :(
| placeholderSrc?: string; | ||
| title?: string; | ||
| } | ||
| const TelemetryDashboard: React.FC<TelemetryDashboardProps> = ({ placeholderSrc, title }) => { |
There was a problem hiding this comment.
Needs to have title = "Live Log Laugh"
| const PropulsionHUD: React.FC<{ leftPower: number; rightPower: number; rudderAngle: number }> = ({ leftPower, rightPower, rudderAngle }) => { | ||
| const getPowerColor = (power: number) => { | ||
| if (power < 60) return '#D8FA07'; | ||
| if (power < 80) return '#f59e0b'; | ||
| return '#ef4444'; | ||
| }; | ||
|
|
||
| const constrainedAngle = Math.max(-30, Math.min(30, rudderAngle)); | ||
| const rudderPosPct = ((constrainedAngle + 30) / 60) * 100; | ||
|
|
||
| return ( | ||
| <div | ||
| data-testid="rudder-visualizer" | ||
| style={{ | ||
| display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '12px 15px', | ||
| background: 'rgba(8, 7, 33, 0.75)', border: '1px solid rgba(255, 255, 255, 0.15)', borderRadius: '8px', | ||
| backdropFilter: 'blur(10px)', width: '230px', color: '#F2F2F2', fontFamily: 'monospace', boxShadow: '0 4px 15px rgba(0, 0, 0, 0.5)' | ||
| }}> | ||
| <div style={{ fontWeight: 'bold', fontSize: '11px', marginBottom: '8px', textTransform: 'uppercase', letterSpacing: '1px', color: '#888' }}>PROPULSION</div> | ||
| <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%', height: '110px', padding: '0 5px' }}> | ||
| {/* Port Thruster */} | ||
| <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}> | ||
| <span style={{ display: 'inline-block', minWidth: '4ch', textAlign: 'center', fontSize: '10px', color: getPowerColor(leftPower), fontWeight: 'bold', marginBottom: '3px' }}>{Math.round(leftPower)}%</span> | ||
| <div style={{ width: '10px', height: '70px', background: 'rgba(255,255,255,0.1)', borderRadius: '2px', position: 'relative', overflow: 'hidden' }}> | ||
| <div style={{ position: 'absolute', bottom: 0, left: 0, width: '100%', height: `${leftPower}%`, background: getPowerColor(leftPower), transition: 'height 0.3s ease, background-color 0.3s ease' }} /> | ||
| </div> | ||
| <span style={{ fontSize: '8px', color: '#888', marginTop: '3px' }}>PORT</span> | ||
| </div> | ||
|
|
||
| {/* SVG Catamaran */} | ||
| <svg width="70" height="95" viewBox="0 0 80 110" style={{ opacity: 0.85 }}> | ||
| <path d="M 16 5 C 10 5, 8 20, 8 45 C 8 70, 8 85, 12 90 C 14 93, 18 93, 20 90 C 22 85, 22 75, 22 65 L 22 25 C 22 15, 20 5, 16 5 Z" fill="#00435C" stroke="#B980F1" strokeWidth="1" /> | ||
| <path d="M 64 5 C 70 5, 72 20, 72 45 C 72 70, 72 85, 68 90 C 66 93, 62 93, 60 90 C 58 85, 58 75, 58 65 L 58 25 C 58 15, 60 5, 64 5 Z" fill="#00435C" stroke="#B980F1" strokeWidth="1" /> | ||
| <rect x="21" y="20" width="38" height="4" fill="#080721" stroke="#D9D9D9" strokeWidth="1" /> | ||
| <rect x="21" y="70" width="38" height="4" fill="#080721" stroke="#D9D9D9" strokeWidth="1" /> | ||
| <path d="M 26 24 C 23 35, 23 60, 26 70" fill="none" stroke="#D9D9D9" strokeWidth="1.5" /> | ||
| <path d="M 54 24 C 57 35, 57 60, 54 70" fill="none" stroke="#D9D9D9" strokeWidth="1.5" /> | ||
| <path d="M 28 32 C 26 45, 26 50, 28 62 L 52 62 C 54 50, 54 45, 52 32 Z" fill="#080721" stroke="#D9D9D9" strokeWidth="1.5" /> | ||
| <rect x="33" y="38" width="14" height="18" rx="2" fill="none" stroke="#B980F1" strokeWidth="1" /> | ||
| <circle cx="35" cy="40" r="1" fill="#D8FA07" /> | ||
| <circle cx="45" cy="40" r="1" fill="#D8FA07" /> | ||
| <circle cx="35" cy="54" r="1" fill="#D8FA07" /> | ||
| <circle cx="45" cy="54" r="1" fill="#D8FA07" /> | ||
| <g transform={`translate(16, 90) rotate(${-constrainedAngle}) translate(-16, -90)`}> | ||
| <rect x="14" y="88" width="4" height="4" fill="#D9D9D9" stroke="#B980F1" strokeWidth="0.5" /> | ||
| <rect x="13" y="92" width="6" height="10" rx="1" fill="#00435C" stroke="#B980F1" strokeWidth="0.5" /> | ||
| <line x1="10" y1="100" x2="22" y2="100" stroke="#D8FA07" strokeWidth="1.5" /> | ||
| </g> | ||
| <g transform={`translate(64, 90) rotate(${-constrainedAngle}) translate(-64, -90)`}> | ||
| <rect x="62" y="88" width="4" height="4" fill="#D9D9D9" stroke="#B980F1" strokeWidth="0.5" /> | ||
| <rect x="61" y="92" width="6" height="10" rx="1" fill="#00435C" stroke="#B980F1" strokeWidth="0.5" /> | ||
| <line x1="58" y1="100" x2="70" y2="100" stroke="#D8FA07" strokeWidth="1.5" /> | ||
| </g> | ||
| </svg> | ||
|
|
||
| {/* Stbd Thruster */} | ||
| <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}> | ||
| <span style={{ display: 'inline-block', minWidth: '4ch', textAlign: 'center', fontSize: '10px', color: getPowerColor(rightPower), fontWeight: 'bold', marginBottom: '3px' }}>{Math.round(rightPower)}%</span> | ||
| <div style={{ width: '10px', height: '70px', background: 'rgba(255,255,255,0.1)', borderRadius: '2px', position: 'relative', overflow: 'hidden' }}> | ||
| <div style={{ position: 'absolute', bottom: 0, left: 0, width: '100%', height: `${rightPower}%`, background: getPowerColor(rightPower), transition: 'height 0.3s ease, background-color 0.3s ease' }} /> | ||
| </div> | ||
| <span style={{ fontSize: '8px', color: '#888', marginTop: '3px' }}>STBD</span> | ||
| </div> | ||
| </div> | ||
| <div style={{ width: '100%', marginTop: '8px', display: 'flex', flexDirection: 'column', alignItems: 'center' }}> | ||
| <div style={{ display: 'flex', justifyContent: 'space-between', width: '100%', fontSize: '9px', color: '#ccc', marginBottom: '2px' }}> | ||
| <span>PORT</span> | ||
| <span style={{ display: 'inline-block', minWidth: '12ch', textAlign: 'center', fontWeight: 'bold', color: '#9ca3af' }}>RUDDER: {Math.round(constrainedAngle)}°</span> | ||
| <span>STBD</span> | ||
| </div> | ||
| <div style={{ width: '100%', height: '5px', background: 'rgba(255,255,255,0.15)', borderRadius: '2px', position: 'relative' }}> | ||
| <div style={{ position: 'absolute', left: '50%', top: 0, width: '1.5px', height: '100%', background: 'rgba(255,255,255,0.4)' }} /> | ||
| <div style={{ position: 'absolute', left: `${rudderPosPct}%`, top: '-3.5px', width: '4px', height: '12px', background: '#e5e7eb', borderRadius: '1.5px', transform: 'translateX(-50%)', transition: 'left 0.2s ease-out' }} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Put this in a different file
| const EventLogsHUD: React.FC<{ title: string; logs: { message: string, timestamp: string }[] }> = ({ title, logs }) => { | ||
| const [collapsed, setCollapsed] = useState(false); | ||
| const displayLogs = logs.slice(-3); | ||
| return ( | ||
| <div style={{ | ||
| display: 'flex', flexDirection: 'column', padding: '10px 15px', background: 'rgba(8, 7, 33, 0.75)', | ||
| border: '1px solid rgba(255, 255, 255, 0.15)', borderRadius: '8px', backdropFilter: 'blur(10px)', | ||
| width: '700px', minHeight: collapsed ? '45px' : '75px', color: '#F2F2F2', fontFamily: 'monospace', boxSizing: 'border-box', boxShadow: '0 4px 15px rgba(0, 0, 0, 0.5)', | ||
| transition: 'min-height 0.2s ease-out' | ||
| }}> | ||
| <div | ||
| className="MuiBox-root" | ||
| onClick={() => setCollapsed(!collapsed)} | ||
| style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', cursor: 'pointer', userSelect: 'none', marginBottom: collapsed ? '0px' : '6px' }} | ||
| > | ||
| <div style={{ fontWeight: 'bold', fontSize: '10px', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px' }}>{title}</div> | ||
| <div style={{ fontSize: '10px', color: '#B980F1', fontWeight: 'bold' }}>{collapsed ? 'Expand' : 'Collapse'}</div> | ||
| </div> | ||
| {!collapsed && ( | ||
| <div style={{ display: 'flex', flexDirection: 'column', gap: '3px', flex: 1, justifyContent: 'center' }}> | ||
| {displayLogs.length > 0 ? ( | ||
| displayLogs.map((log, idx) => ( | ||
| <div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> | ||
| <div style={{ fontSize: '11px', color: '#e5e7eb', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap' }}>• {log.message}</div> | ||
| <div style={{ fontSize: '10px', color: '#B980F1', opacity: 0.8, whiteSpace: 'nowrap' }}>[{log.timestamp}]</div> | ||
| </div> | ||
| )) | ||
| ) : ( | ||
| <div style={{ fontSize: '11px', color: '#6b7280', fontStyle: 'italic' }}>No log entries available</div> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; |
| const measureLocalMeters = (lat1: number, lon1: number, lat2: number, lon2: number) => { | ||
| const R = 6378137; // Earth’s radius in meters | ||
| const dLat = (lat2 - lat1) * Math.PI / 180; | ||
| const dLon = (lon2 - lon1) * Math.PI / 180; | ||
| const x = dLon * Math.cos((lat1 * Math.PI) / 180) * R; | ||
| const y = dLat * R; | ||
| return { x, y }; | ||
| }; |
| thrusterPower: state.telemetry.motors, | ||
| connectionStatus: state.telemetry.signal.strength > 0 ? 'connected' : 'disconnected', | ||
| signalStrength: state.telemetry.signal.strength, | ||
| batteryLevel: state.telemetry.battery.primary, |
There was a problem hiding this comment.
there is more than one battery. infact 2
| }; | ||
|
|
||
| // 4. System Status Panel | ||
| const SystemStatusHUD: React.FC<{ connectionStatus: string; batteryLevel: number; autonomyMode: boolean; signalStrength: number }> = ({ connectionStatus, batteryLevel, autonomyMode, signalStrength }) => { |
There was a problem hiding this comment.
why are we prop drillling in the same file?
| <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}> | ||
| <span style={{ color: '#D9D9D9', fontSize: '11px' }}>BAT:</span> | ||
| <span style={{ display: 'inline-block', minWidth: '4ch', textAlign: 'right', fontWeight: 'bold', color: batteryLevel < 20 ? '#ef4444' : '#D8FA07' }}>{Math.round(batteryLevel)}%</span> | ||
| </div> |
There was a problem hiding this comment.
review src/components/hud/telemetry/Batteries.tsx because we are using icons
| type CourseTrailPoint = { | ||
| x: number; | ||
| y: number; | ||
| h: number; |
|
Also @S7VN-DEV we are using MUI maybe use their components instead of |
Give 'er a try, still needs some work and bug fixing and longer tests. @TheFujirose see if you can try to feed it real data